﻿using System.Collections.Specialized;
using System.Linq;

namespace TraceView.UI.Entities
{
    public sealed class RecentItemsCollection : FilteredTraceItemCollection
    {
        public RecentItemsCollection(TraceItemCollection masterList, IFilterCollectionMatchCriteria[] filters)
            : base(masterList, filters) {}

        protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
        {
            base.OnCollectionChanged(e);
            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                if (Count > 5)
                {
                    for (int i = Count - 1; i >= Count; i--)
                        RemoveAt(i);
                }
            }
        }
    }
}